<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('index')}">机构列表</a></li>
			<li class="active"><a href="">添加</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('add')}">
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label"><span class="form-required">*</span>名称</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-name" required name="name">
				</div>
			</div>
			<div class="form-group">
				<label for="select-type" class="col-sm-2 control-label"><span class="form-required">*</span>机构类型</label>
				<div class="col-md-6 col-sm-10">
					<select name="type" id="select-type" class="form-control">
						<volist name="types" id="vo">
							<option value="{$vo.id}">{$vo.name}</option>
						</volist>
					</select>
				</div>
			</div>
			<div class="form-group gs_cycle">
				<label for="input-gs_cycle" class="col-sm-2 control-label"><span class="form-required">*</span>工商执照周期</label>
				<div class="col-md-6 col-sm-10">
					<div class="input-group">
						<input type="number" class="form-control" id="input-gs_cycle" required name="gs_cycle">
						<span class="input-group-addon">天</span>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label for="select-area" class="col-sm-2 control-label"><span class="form-required">*</span>地区</label>
				<div class="col-md-6 col-sm-10">
					<div class="input-group">
						<span class="input-group-addon">省</span>
						<select name="area" id="select-area" class="form-control">
							<volist name="areas" id="vo">
								<option value="{$vo.areaid}">{$vo.name}</option>
							</volist>
						</select>
						<span class="input-group-addon">市</span>
						<select name="city" id="select-city" class="form-control">
						</select>
						<span class="input-group-addon">区</span>
						<select name="qu" id="select-qu" class="form-control">
						</select>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label for="input-address" class="col-sm-2 control-label"><span class="form-required">*</span>详细地址</label>
				<div class="col-md-6 col-sm-10">
					<input type="tel" class="form-control" id="input-address" required name="address">
				</div>
			</div>
			<div class="form-group">
				<label for="select-relations" class="col-sm-2 control-label"><span class="form-required">*</span>是否公关</label>
				<div class="col-md-6 col-sm-10">
					<select name="relations" id="select-relations" class="form-control">
						<option value="0">未公关</option>
						<option value="1">已公关</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label for="textarea-policy" class="col-sm-2 control-label">差异政策</label>
				<div class="col-md-6 col-sm-10">
					<textarea name="policy" class="form-control" id="textarea-policy" rows="3"></textarea>
				</div>
			</div>
			<div class="form-group">
				<label for="textarea-remark" class="col-sm-2 control-label">备注</label>
				<div class="col-md-6 col-sm-10">
					<textarea name="remark" class="form-control" id="textarea-remark" rows="3"></textarea>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
					<a class="btn btn-default" href="javascript:history.back(-1);">返回</a>
				</div>
			</div>
		</form>
	</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
	$(function(){
	    $('#select-type').change(function(){
			if($(this).val() == 0){
			    $('.gs_cycle').show();
			}else{
                $('.gs_cycle').hide();
			}
		})
        setcity();
        $('#select-area').change(function(){
            setcity();
		});
	    function setcity() {
	        $.ajax({
				url:"{:cmf_url('areas/area')}",
				data:{areaid:$('#select-area').val()},
				success:function(data) {
                    $('#select-city').html('<option value="0">全部</option>')
                    $('#select-qu').html('<option value="0">全部</option>')
				    $.each(data.data,function(key,item){
                        $('#select-city').append('<option value="'+item.areaid+'">'+item.name+'</option>')
					})
				}
			})
		}
        $('#select-city').change(function(){
            setqu();
        });
	    function setqu() {
	        $.ajax({
				url:"{:cmf_url('areas/area')}",
				data:{areaid:$('#select-city').val()},
				success:function(data) {
                    $('#select-qu').html('<option value="0">全部</option>')
				    $.each(data.data,function(key,item){
                        $('#select-qu').append('<option value="'+item.areaid+'">'+item.name+'</option>')
					})
				}
			})
		}
	})
</script>
</body>
</html>